package com.test.webflux.config;

import com.test.webflux.config.router.CommonRouter;
import com.test.webflux.config.router.ProductRouter;
import com.test.webflux.config.router.UserRouter;
import com.test.webflux.service.ProductService;
import com.test.webflux.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * 路由配置2
 *
 * @Description
 * @Author lingmin
 * @Date 2025/4/14 15:45
 **/
//@Configuration
public class RouterFunctionConfig {


    @Bean
    public RouterFunction<ServerResponse> commonRoutes() {
        CommonRouter commonRouter = new CommonRouter();
        return commonRouter.commonRoutes();
    }


    @Bean
    public RouterFunction<ServerResponse> busRoutes(UserService userService , ProductService productService) {
        UserRouter userRouter = new UserRouter();
        ProductRouter productRouter = new ProductRouter();
        return userRouter.userRoutes(userService).and(productRouter.productRoutes(productService));
    }
}
